Language: Mobile System Language
EdgerOS App can get current language information.
Functions
edger.language()
- Returns: {Promise} Promise object.
Get current EdgerOS language information.
Example
edger.language().then((data) => {
const { lang, name } = data;
console.log('Current language:', lang, name);
}).catch(error => {
console.error(error);
});
async / await
async function language() {
try {
return await edger.language();
} catch (error) {
console.error(error);
}
}
The obtained data
object contains the following members:
lang
{String} Language code.name
{String} Language name.
The lang
and name
possible values include:
lang | name |
---|---|
'zh-CN' | '中文 (简体)' |
'zh-TW' | '中文 (繁体)' |
'en' | 'English' |
'fr' | 'français' |
'de' | 'Deutsche' |
'it' | 'italiano' |
'ja' | '日本語' |
'kr' | '한국어' |
'es' | 'Español' |
'pt' | 'portugués' |
Events
The unified event listener provided by Web-SDK:
const listener = (payload) => {
// Event handling...
}
// add listener
edger.addEventListener('some-event', listener);
// or
// onAction() is an alias of addEventListener().
edger.onAction('some-event', listener);
// remove listener
edger.removeEventListener('some-event', listener);
// remove all listeners
edger.removeAllListeners();
language
This event will be generated when EdgerOS switches the language.
Example
const listener = (payload) => {
const { lang, name } = payload;
console.log('Current language:', lang, name);
}
edger.addEventListener('language', listener);